1. Field of the Invention
The present invention relates to a drawing device, a drawing method, and a drawing program. More particularly, the present invention relates to a drawing device, a drawing method, and a drawing program for drawing, on a polygon image, a mipmap image, which is a texture image of a surface of a displayed object in three-dimensional computer graphics.
2. Description of the Background Art
Conventionally, there is a known technique called texture mapping as a three-dimensional computer graphics technique, in which a texture image is drawn on a polygon image of a three-dimensional object. The term “texture image” refers to an image which represents a pattern on a surface of a displayed object.
In three-dimensional computer graphics, a three-dimensional object is formed of a set of images (called “polygon images”) of planar polygons (generally limited to triangles). A polygon image is defined by a three-dimensional coordinate system called a “world coordinate system”. In order to display a three-dimensional object on a display unit (e.g., an LCD monitor, etc.), a geometric transform process is performed so that “world coordinates” which are defined for the three-dimensional object are transformed into coordinates in a two-dimensional coordinate system called a “screen coordinate system”. The screen coordinate system is a two-dimensional coordinate system in which the coordinates of the upper left endpoint of a display screen is defined as (0, 0). For example, when the display unit is formed of a display device having 1920 pixels (width)×1080 pixels (length), the screen coordinate values can take numerical values ranging from (0, 0) to (1919, 1079). An exemplary original image of a texture and an exemplary polygon image which has been transformed into an image in the screen coordinate system are shown in FIG. 17. A portion (a) of FIG. 17 is a diagram showing the exemplary polygon image which has been transformed into an image in the screen coordinate system. A portion (b) of FIG. 17 is a diagram showing the exemplary original image of a texture. In the portion (a) of FIG. 17, As, Bs, and Cs are points indicating the vertices of the polygon image. The screen coordinates of the vertices are As(Xa, Ya), Bs(Xb, Yb), and Cs(Xc, Yc). Note that, as shown in the portion (a) of FIG. 17, texture coordinates (described below) as well as the screen coordinates are indicated for each vertex.
Texture mapping is performed using an original image of a texture and two numerical values (texture coordinates) indicating a place in the original image. In the portion (b) of FIG. 17, if the original texture image has, for example, a size of 1024 pixels both in length and in width, the texture coordinate values can take numerical values between (0, 0) and (1023, 1023). It is here assumed that a texture coordinate point corresponding to the vertex As of the polygon image is At(Ua, Va), a texture coordinate point corresponding to the vertex Bs is Bt(Ub, Vb), and a texture coordinate point corresponding to the vertex Cs is Ct (Uc, Vc). In this case, texture mapping is performed by mapping from At to As, from Bt to Bs, and from Ct to Cs. Note that, in this case, the shape of the polygon image formed of the vertices As to Cs is smaller than the shape of the original texture image formed of the vertices At to Ct. Therefore, the original texture image is reduced by the above-described texture mapping.
However, when the original texture image is reduced and processed, aliasing noise disadvantageously occurs as in image reducing processes and audio downsampling processes. To avoid such a problem, a technique of using a “mipmap image” has been proposed (see, for example, Mason Woo, et al., “The Official Guide to Learning Opengl, Version 1.1”, US, Addison-Wesley, 1997, p. 339). A mipmap image is an image which is generated by reducing an original texture image successively into mipmap levels as shown in FIG. 18. FIG. 18 is a diagram showing an exemplary mipmap image. A portion (a) of FIG. 18 is a diagram showing an exemplary original texture image. A portion (b) of FIG. 18 is a diagram showing a mipmap image at a mipmap level 1. A portion (c) of FIG. 18 is a diagram showing a mipmap image at a mipmap level 2. A portion (d) of FIG. 18 is a diagram showing a mipmap image at a mipmap level 3. A portion (e) of FIG. 18 is a diagram showing a mipmap image at a mipmap level 4. In the portions (a) to (e) of FIG. 18, numerical values in rectangles indicate luminance values. The mipmap image at the mipmap level 1 is an image obtained by reducing the original texture image by a factor of 2 in both the lengthwise and widthwise directions. The mipmap images at the mipmap levels 2 to 4 are images obtained by reducing the respective immediately previous images by a factor of 2 in both the lengthwise and widthwise directions.
Hereinafter, a method for generating a mipmap image will be specifically described. When a mipmap image at the mipmap level 1 is generated, the average of luminances of four neighboring pixels in an original texture image is calculated. In the original image of the portion (a) of FIG. 18, the average of a luminance of 32 at (U0, V0), a luminance of 40 at (U0, V1), a luminance of 32 at (U1, V0), and a luminance of 40 at (U1, V1) is 36. The luminance of 36 is set into the value of a luminance at (U0, V0) of a mipmap image at the mipmap level 1 in the portion (b) of FIG. 18. Similarly, the average of luminances at (U2, V0), (U2, V1), (U3, V0), and (U3, V1) in the original image is set into the value of a luminance at (U1, V0) of the mipmap image at the mipmap level 1. In this manner, a mipmap image at each mipmap level is generated by calculating the average of luminances at four neighboring pixels of a mipmap image at the immediately previous mipmap level. To average the luminances of four neighboring pixels to generate a mipmap image also serves as a low-pass filter, thereby making it possible to prevent the occurrence of aliasing noise described above.
Hereinafter, a conventional drawing device 5 in which the above-described technique of using a mipmap image is implemented will be described with reference to FIG. 19. FIG. 19 is a diagram showing units constituting the conventional drawing device 5. The units constituting the drawing device 5 are interconnected via an internal bus. The units each perform a process by writing or reading data to or from a main memory 6 via a memory I/F (memory interface) 57.
From a storage medium (e.g., a CD-ROM, etc.) in which an original texture image which is a still image is stored, a mipmap generating unit 51 reads out the original image using a CD-ROM drive (not shown) or the like. The mipmap generating unit 51 generates mipmap images at the mipmap levels 1 and more from the read original image using the generation method described above. The generated mipmap images at the mipmap levels are written into the main memory 6. A polygon geometric transformation unit 53 transforms world coordinates defined in a polygon image into screen coordinates. The polygon geometric transformation unit 53 also compares the screen coordinates of points in the polygon image and the texture coordinates of corresponding points in the original image so as to calculate a reduction ratio of the original image. The polygon geometric transformation unit 53 obtains a required mipmap level from the calculated reduction ratio. A texture referencing unit 52 reads out a mipmap image at the obtained mipmap level from the main memory 6 and outputs the mipmap image to a polygon drawing unit 54. The polygon drawing unit 54 draws the mipmap image output from the texture referencing unit 52 on the polygon image. The polygon image on which the mipmap image is drawn is written into the main memory 6. A liquid crystal panel 7 is controlled by a video controller 55 to display the polygon image on which the mipmap image is drawn. A CPU 56 controls the whole processes of the units.
Thus, the conventional drawing device 5 generates and stores a number of kinds of mipmap images into the main memory 6 connected to the drawing device 5, and reads out a required mipmap image from the main memory 6 and draws the mipmap image on a polygon image.
However, in the conventional drawing device 5, when texture mapping is performed, a number of kinds of mipmap images need to be stored in the main memory 6 connected to the drawing device 5. Also, the data amount of those mipmap images is large. Therefore, the main memory 6 disadvantageously needs to have a large storage capacity. Further, when a texture image which is a moving image is used, a number of kinds of mipmap images need to be generated and stored in the main memory 6 for each frame. Therefore, when a texture image which is a moving image is used, the band congestion of the main memory 6 disadvantageously occurs.